#include "DataStructure/Input/Constraint/RBE2Data.h"

#include "DataStructure/Common/Validation.h"
#include "DataStructure/Input/Solver/DOFDirections.h"

using namespace SG::DataStructure;

/**
 * @brief 获取从属自由度集合
 *
 * 返回从属自由度集合的实例。
 *
 * @return 从属自由度集合的实例
 */
SG::DataStructure::FEM::DofSet FEM::RBE2Data::GetSlaveDofs () const
{
    return Int2VDofSet (m_slaveDOFs);
}

/**
 * @brief 添加从属自由度实例
 *
 * 返回从属自由度集合。
 *
 * @return 从属自由度集合
 */
void FEM::RBE2Data::SetSlaveDOFs (const SG::DataStructure::FEM::DofSet& dofs)
{
    m_slaveDOFs = DofSet2Int (dofs);
}

/// @brief 判断两个RBE2Data是否相等
/// @param lhs
/// @param rhs
/// @return
bool SG::DataStructure::FEM::operator== (const RBE2Data& lhs, const RBE2Data& rhs)
{
    if (lhs.m_id != rhs.m_id)
    {
        return false;
    }
    if (lhs.m_masterNode != rhs.m_masterNode)
    {
        return false;
    }
    if (lhs.m_slaveDOFs != rhs.m_slaveDOFs)
    {
        return false;
    }
    if (!SG::DataStructure::Common::isNear (lhs.m_alpha, rhs.m_alpha))
    {
        return false;
    }
    if (!SG::DataStructure::Common::isNear (lhs.m_refTemperature, rhs.m_refTemperature))
    {
        return false;
    }
    if (lhs.m_domainId != rhs.m_domainId)
    {
        return false;
    }
    if (lhs.m_slaveNodes != rhs.m_slaveNodes)
    {
        return false;
    }
    if (lhs.m_slaveDOFs != rhs.m_slaveDOFs)
    {
        return false;
    }
    return true;
}
